package org.codeart.strategy.example03;

import org.codeart.strategy.pojo.Receipt;

import java.util.HashMap;
import java.util.Map;

public class ReceiptHandleStrategyFactory {
    
    // 使用 Map 存储策略信息
    private final Map<String, ReceiptHandleStrategy> strategies = new HashMap<>();

    /**
     * 具体策略，保存到 Map 集合
     */
    public ReceiptHandleStrategyFactory() {
        strategies.put("MT1101", new MT1101ReceiptHandleStrategy());
        strategies.put("MT2101", new MT2101ReceiptHandleStrategy());
        strategies.put("MT4101", new MT4101ReceiptHandleStrategy());
        strategies.put("MT8101", new MT8101ReceiptHandleStrategy());
    }

    public ReceiptHandleStrategy get(Receipt receipt) {
        return strategies.get(receipt.getType());
    }
}
